/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.amse.grigory.dchess.kernel;

/**
 *
 * @author grigory
 */
public final class Square {

    // Fields
    private Figure myFigure;
    private boolean myMoved;
    private int myColor;
    private int myIllegal;

    // Constructors
    public Square() {
        myFigure = null;
        myColor = 0;
        myIllegal = 0;
        myMoved = false;
    }

    public Square(Figure figure) {
        this();
        if (figure==null){
            myFigure=null;
        }else{
            myFigure = figure.clone();            
        }
        
    }

    // Setters
    public void setColor(int color) {
        myColor = color;
    }

    public void setIllegal(int t) {
        myIllegal = t;
    }

    public void setFigure(Figure figure) {
        if (figure == null) {
            myFigure = null;
            return;
        }
        myFigure = figure.clone();
    }

    public void setMoved(boolean moved) {
        myMoved = moved;
    }
    // Getters

    public int getColor() {
        return myColor;
    }

    public int getIllegal() {
        return myIllegal;
    }

    public Figure getFigure() {
        return myFigure;
    }

    public boolean getMoved() {
        return myMoved;
    }

    public Square clone() {
        Square temp = new Square(myFigure);
        temp.setColor(myColor);
        temp.setIllegal(myIllegal);
        temp.setMoved(myMoved);
        return temp;
    }
}
